package student.aistar.day15.homework01;

/**
 * 账户 - "临界资源" - 多个线程竞争得资源
 */
public class Account {
    private Integer id;

    private double balance = 100;//余额

    public Account() {
    }

    public Account(Integer id, double balance) {
        this.id = id;
        this.balance = balance;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    //取钱的操作
    public void change(double money){
        this.balance-=money;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Account{");
        sb.append("id=").append(id);
        sb.append(", balance=").append(balance);
        sb.append('}');
        return sb.toString();
    }
}
